<!--

    Copyright (C) 2015 The Gravitee team (http://gravitee.io)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<h3>General</h3>
<md-input-container ng-if="!$ctrl.isMarkdownTemplate()" class="md-block gv-input-container-dense">
  <md-checkbox ng-model="$ctrl.page.homepage" aria-label="set as homepage" class="md-align-top-left" flex> Set as homepage </md-checkbox>
</md-input-container>

<md-input-container class="md-block gv-input-container-dense">
  <md-checkbox
    ng-model="$ctrl.page.published"
    aria-label="{{!$ctrl.isMarkdownTemplate() ? 'Published' : 'Available'}}"
    class="md-align-top-left"
    flex
    ng-disabled="$ctrl.usedAsGeneralConditions()"
  >
    {{($ctrl.usedAsGeneralConditions() ? 'Publish this page (Used as general conditions, publishing actions are disabled)' :
    !$ctrl.isMarkdownTemplate() ? 'Publish this page' : 'Make template available')}}
  </md-checkbox>
</md-input-container>

<!-- SWAGGER Configuration -->
<div ng-if="$ctrl.isSwagger()" layout="column">
  <div ng-if="$ctrl.shouldShowOpenApiDocFormat">
    <h3>OpenAPI documentation viewer:</h3>
    <md-radio-group ng-model="$ctrl.page.configuration.viewer">
      <md-radio-button value="Swagger" class="md-primary">{{ $ctrl.openApiFormatLabel('Swagger') }}</md-radio-button>
      <md-radio-button value="Redoc">{{ $ctrl.openApiFormatLabel('Redoc') }}</md-radio-button>
    </md-radio-group>
  </div>

  <md-checkbox
    ng-model="$ctrl.page.configuration.entrypointsAsServers"
    ng-true-value="'true'"
    ng-false-value="'false'"
    ng-click="$ctrl.toggleEntrypointAsServer()"
  >
    Use entrypoints of the API as server urls (in that case, the base URL is no more used).
  </md-checkbox>

  <md-input-container class="md-block">
    <label>Base URL</label>
    <input
      type="text"
      ng-model="$ctrl.page.configuration.tryItURL"
      ng-disabled="$ctrl.page.configuration.entrypointsAsServers === 'true'"
    />
    <div class="hint">
      Custom base URL to use as server url (if empty and not using api's entrypoints, the server url of the swagger / openapi descriptor
      will be used).
    </div>
  </md-input-container>

  <md-checkbox ng-model="$ctrl.page.configuration.entrypointAsBasePath" ng-true-value="'true'" ng-false-value="'false'">
    Use context-path of the API (this will replace the path of the server url with the context-path of the API)
  </md-checkbox>

  <div ng-if="$ctrl.page.configuration.viewer === 'Swagger'" layout="column">
    <h3>Swagger</h3>
    <md-checkbox ng-model="$ctrl.page.configuration.tryIt" ng-true-value="'true'" ng-false-value="'false'">
      Enable "Try it!" mode. Perhaps you will have to configure the CORS in the proxy section.
    </md-checkbox>
    <md-checkbox ng-model="$ctrl.page.configuration.tryItAnonymous" ng-true-value="'true'" ng-false-value="'false'">
      Allow "Try it!" for anonymous users
    </md-checkbox>
    <md-checkbox ng-model="$ctrl.page.configuration.showURL" ng-true-value="'true'" ng-false-value="'false'">
      Show the URL to download the content
    </md-checkbox>
    <md-checkbox ng-model="$ctrl.page.configuration.displayOperationId" ng-true-value="'true'" ng-false-value="'false'">
      Display the operationId in the operations list
    </md-checkbox>
    <md-input-container class="md-block">
      <label>Default expansion setting for the operations and tags</label>
      <md-select ng-model="$ctrl.page.configuration.docExpansion">
        <md-option ng-value="'list'">Expands only the tags</md-option>
        <md-option ng-value="'full'">Expands the tags and operations</md-option>
        <md-option ng-value="'none'">Expands nothing</md-option>
      </md-select>
    </md-input-container>
    <md-checkbox ng-model="$ctrl.page.configuration.enableFiltering" ng-true-value="'true'" ng-false-value="'false'" class="md-block">
      Add a top bar to filter content
    </md-checkbox>
    <md-checkbox ng-model="$ctrl.page.configuration.showExtensions" ng-true-value="'true'" ng-false-value="'false'" class="md-block">
      Display vendor extension (X-) fields and values for Operations, Parameters, and Schema
    </md-checkbox>
    <md-checkbox ng-model="$ctrl.page.configuration.showCommonExtensions" ng-true-value="'true'" ng-false-value="'false'">
      Display extensions (pattern, maxLength, minLength, maximum, minimum) fields and values for Parameters
    </md-checkbox>
    <md-input-container class="md-block">
      <label>Number of max tagged operations displayed</label>
      <input type="number" ng-model="$ctrl.page.configuration.maxDisplayedTags" />
      <div class="hint">Limits the number of tagged operations displayed to at most this many (-1 means show all operations).</div>
    </md-input-container>
  </div>
</div>
